package com.yw.smartcity_study;

import android.content.Context;
import android.content.SharedPreferences;

public class SPUtil {
    private static SPUtil instance = new SPUtil();
    private SharedPreferences sp;
    private SPUtil(){
        sp = App.app.getSharedPreferences("smart_city", Context.MODE_PRIVATE);
    }
    public static SPUtil getInstance(){
        return instance;
    }

    public Boolean getBoolean(String key, boolean defaultValue){
        return sp.getBoolean(key, defaultValue);
    }

    public void  saveBoolean(String key, Boolean value){
        sp.edit().putBoolean(key, value).apply();
    }

    public void saveString(String key, String value){
        sp.edit().putString(key, value).apply();
    }
    public String getString(String key, String defaultValue){
        return sp.getString(key, defaultValue);
    }

}
